package net.chensee.avastxa.logic.handler.resolve;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class RequsetMapping {

    public Map<String, RequestResolver> rrMap = new ConcurrentHashMap<>();

    private static RequsetMapping instance = new RequsetMapping();

    public static RequsetMapping getInstance() {
        return instance;
    }

    private RequsetMapping() {}

    public void reg(String path, RequestResolver resolver) {
        if (resolver == null) {
            return;
        }
        RequestResolver r = rrMap.get(path);
        if (r != null) {
            r.setLast(resolver);
        }
        rrMap.put(path, resolver);
    }

    public RequestResolver resolver(String path) {
        return rrMap.get(path);
    }

}
